﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml
Public Class List_page
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        ' this is a code for search 


        If TextBox2.Text <> "" Then

            Dim cost As Integer


            Try

                ' Convert textbox to integer

                cost = Convert.ToInt32(TextBox2.Text)



            Catch ex As Exception

                cost = 0

            End Try


            Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\CruisesDB.accdb;Persist Security Info=True"



            Dim SqlString As String = "SELECT CruisesTable.CId, CruisesTable.CTitle, CruisesTable.CDate, CruisesTable.CTime, CruisesTable.CSeason, CruisesTable.CCountry, CruisesTable.CCity, CruisesTable.CPlace, CruisesTable.CCoste, CruisesTable.CDescription, CruisesTable.CThumbnail, CruisesTable.Cuserid, CruisesTable.CCreatedate, Users.Uname, Users.UId, Users.[Personal Picture] FROM CruisesTable INNER JOIN Users ON CruisesTable.Cuserid = Users.UId WHERE (CruisesTable.CTitle LIKE '%" & TextBox2.Text & "%') OR (CruisesTable.CSeason LIKE '%" & TextBox2.Text & "%') OR (CruisesTable.CCountry LIKE '%" & TextBox2.Text & "%') OR (CruisesTable.CCity LIKE '%" & TextBox2.Text & "%') OR (CruisesTable.CPlace LIKE '%" & TextBox2.Text & "%') OR (CruisesTable.CCoste =" & cost & ")"

            SqlDataSourceCruisesTable.SelectCommand = SqlString


            'view search result in the gridview

            GridView2.DataBind()

        End If

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
        Response.Redirect("AddCruises.aspx")
    End Sub
End Class